package controller

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"publiclib/stateless"
	"user-server/module/user"
)

func init() {
	RegisterRouterFn(newCustRouter("GET", v1_api+"/test", handleTest)) // 测试
}

func handleTest(ctx *gin.Context) {
	phone := ctx.Query("phone")
	if phone == "" {
		ctx.JSON(http.StatusOK, genNormalAppErrorResp(stateless.ErrParam, "key请求参数错误！"))
		return
	}

	srv := user.NewUserService()
	data, errno, errStr := srv.Test(phone)
	if errno != stateless.Success {
		ctx.JSON(200, genNormalAppErrorResp(errno, errStr))
		return
	}

	result := map[string]interface{}{
		"data": data,
	}

	ctx.JSON(200, genNormalAppResponseToJson(result, ""))

}
